<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>微信二维码登录</title>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/qrcode.min.js"></script>
</head>
<body>
<div id="qrcode"></div>
</body>

<script th:inline="javascript">
    const url = [[${url}]];
    new QRCode("qrcode", {
        text: url,
        width: 250,
        height: 250,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });

    const state = [[${state}]];
    // 开启定时任务，查询登录状态
    const taskId = setInterval(() => {
        $.ajax({
            url: "/api/ucenter/wx/checkLogin?state="+state,
            type: "GET",
            success: function (data) {
                if(data.success){
                    window.clearInterval(taskId);
                    location.href = "http://localhost:3000";
                }
            }
        });
    }, 3000);
</script>
</html>